package practice;

public class 复制数组 {
    public static void main(String[] args) {
        int a[] = {1,2,3,4,5,6,7,8,9,10};
        printArr(copeArr(a,3,7));
    }
    public static int[] copeArr(int a[],int form,int to){
        int newArr[] = new int[to  - form +1  ];
        for (int i = 0;form - 1 <to ;form++,i++){
            newArr[i] = a[form - 1];
        }

        return newArr;
    }
    public static void printArr(int[] arr){
        System.out.print("[");
        for(int i=0;i<arr.length;i++){
            if(i==arr.length-1){
                System.out.print(arr[i]);
            }else {
                System.out.print(arr[i]+",");
            }
        }
        System.out.print("]");

    }
}
